
%1.2
% c=[1;2;3;4;1;2;3;4];b=[0;1;-1/2];
% a=[1,-1,-1,1
%     1,-1,1,-3
%     1,-1,-2,3];
% a=[a,-a];
% [t,val]=linprog(c,[],[],a,b,zeros(8,1));
% x=t(1:4)-t(5:8);

% 1.4
% q=[0, 2.5, 1.5, 5.5, 2.6]/100; r=[5, 28, 21, 23, 25]/100;
% p=[0, 1, 2, 4.5, 6.5]/100;
% %投资数额定值
% M=1;
% h=0.04;
% hold on
% while h<0.26
%   c=[0,0,0,0,0,1];
%   A=[0,0.025,0,0,0,-1
%    0,0,0.015,0,0,-1
%    0,0,0,0.055,0,-1
%    0,0,0,0,0.026,-1
%    -0.05,-0.27,-0.19,-0.185,-0.185,0];
%   b=[0,0,0,0,-h];
%   Aeq=[1,1.01,1.02,1.045,1.065,0];
%   beq=M;
%    [x,t] =linprog(c,A,b,Aeq,beq,zeros(6,1));
%    t=-t;
%    plot(h,t,'*r');
%    h=h+0.01;
% end
% xlabel(h),ylabel(t);
% clc,clear;
%1.5
% 由题目可知各制造一件分别占用设备A和B的台时
% 调试工序时间，每天可用于这两种产品的加工时间
% 各销售一件时的获利情况都与1，2的产品数有关。因此将其
% 看成决策变量，即目标函数为max z=2x(1)+x(2)
% 约束条件为{ 5*x(2)<=15 x(1)+x(2)<=5 6*x(1)+2*x(2)<=24 x(1)>=0 x(2)>=0 }
% c=[-2,-1];
% A=[0,1
%    1,1
%    3,1];
% b=[3,5,12];
% [x,z]=linprog(c,A,b,[],[],zeros(2,1));
% z=-z;
% x1=x(1);
% x2=x(2);
% 最优解便是x1=3.5,x2=1.5.
% 
% clc ,clear;
% 1.9
% c=[20,90,80,70,30];
% A=[-1,-1,0,0,-1
%    0,0,-1,-1,0
%    3,0,2,0,0
%    0,3,0,2,1];
% b=[-30,-30,120,48];
% intcon=[1,2,3,4,5];
% [x,z]=intlinprog(c,intcon,A,b,[],[],zeros(5,1));
% 

clc,clear;
% 1.8
% 设i代表糖的种类i=1,2;j代表原料的使用j=1,2,3;xij作为决策变量;
% 生产总量即为c1=x11+x12+x13,c2=x21+x22+x23;
% 所以利润z=24*c1+15*c2-(x11+x21)*20-(x12+x22)*12-(x13+x23)*8
% 约束条件有{x11>=50%c1,x12>=25%c1,x13<=10%c1,x21<=40%c2,x22<=40%c2,x23>=15%c2
% x11+x21<=600,x12+x22<=750,x13+x23<=625,c1>=600,c2>=800,而且xij>=0}
% c=[4,12,16,-5,3,7]
% A=[-1,1,1,0,0,0
%     1,-3,1,0,0,0
%     -1,-1,9,0,0,0
%     0,0,0,3,-2,-2
%     0,0,0,-2,3,-2
%     0,0,0,0.15,0.15,-0.85
%     1,0,0,1,0,0
%     0,1,0,0,1,0
%     0,0,1,0,0,1
%     -1,-1,-1,0,0,0
%     0,0,0,-1,-1,-1];
% b=[0,0,0,0,0,0,600,750,625,-600,-800];
% [x,val]=linprog(-c,A,b,[],[],zeros(6,1));
% val=-val;
%最大利润即为val=14200

